<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>店面短信充值日志管理</title>
	<meta name="decorator" content="default"/>
	<style type="text/css">
		body {overflow:scroll;}
	</style>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#smsRechargeMoney").keyup(function(){
				var money = $("#smsRechargeMoney").val();
				var moneyInt = "";
				moneyInt = parseInt(money);
				if(moneyInt > 0){
					$("#smsRechargeAmount").val(parseInt("${smsRate}")*moneyInt);
				} else {
					$("#smsRechargeAmount").val('');
				}
			});
			$("#inputForm").validate({
				rules:{
					"smsRechargeMoney": "ifMoney"
	            },
				submitHandler: function(form){
					var money = $("#smsRechargeMoney").val();
					var moneyInt = "";
					moneyInt = parseInt(money);
					if(moneyInt > parseInt("${storeRechargeSmsLog.store.account_balance}")){
						showTip('余额不足，无法充值！');
					} else {
						bossLoginSubmit("${fns:getStore().bossPassword}", form, 'search');
					}
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			$("textarea").focus(function(){
				$("body").height($('#right', parent.document).height());
				this.scrollIntoView();
				});
		});
	</script>
</head>
<body>
	<form:form id="inputForm" modelAttribute="storeRechargeSmsLog" action="${ctx}/sms/storeRechargeSmsLog/save" method="post" class="form-input">
		<form:hidden path="id"/>
		<form:hidden path="store.id" value="${fns:getStore().id}"/>
		<tags:message content="${message}"/>
	    <div data-role="collapsible" data-collapsed="false" >
	        <h3>店面信息</h3>
	        <div data-role="fieldcontain">
		        <label>店名：</label><label>${storeRechargeSmsLog.store.name}</label>
		    </div>
	        <div data-role="fieldcontain">
		        <label>剩余金额：</label><label>${storeRechargeSmsLog.store.account_balance}&nbsp;元</label>
		    </div>
	        <div data-role="fieldcontain">
		        <label>剩余短信：</label><label>${storeRechargeSmsLog.store.sms_remain_amount}&nbsp;条</label>
		    </div>
	        <div data-role="fieldcontain">
		        <label>短信充值费率：</label><label>一元钱可以充值短信${smsRate}条</label>
		    </div>
	    </div>
	    <div data-role="collapsible" data-collapsed="false">
	        <h3>短信充值</h3>
	        <div data-role="fieldcontain">
				<label for="smsRechargeMoney">充值金额：</label>
				<form:input id="smsRechargeMoney" path="smsRechargeMoney" htmlEscape="false" maxlength="10" class="required"/>
			</div>
	        <div data-role="fieldcontain">
				<label for="smsRechargeAmount">转换为短信的条数：</label>
				<form:input readonly="true" id="smsRechargeAmount" path="smsRechargeAmount" htmlEscape="false" maxlength="10" class="required digits"/>
			</div>
	    </div>
		<div class="icon-buttons">
			<input type="button" class="leave-not-clean-session" data-inline="true" data-icon="back" data-iconpos="notext" value="返回"/>
			<input data-inline="true"  type="submit" data-icon="check" data-iconpos="notext" value="确定充值"/>
		</div>
	</form:form>
</body>
</html>
